/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: SysLogServiceImpl
 * Author:   pc
 * Date:     2019/9/9 15:48
 * Description: 日志服务类
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.example.rabbitmqdemo.service.impl;


import com.example.rabbitmqdemo.Repository.SysLogRepository;
import com.example.rabbitmqdemo.entity.SysLog;
import com.example.rabbitmqdemo.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

/**
 * 〈功能：〉<br> 
 * 〈日志服务类〉
 * @author liuhaoran
 * @create 2019/9/9 15:48
 * @since 1.0.0
 */
@Service
public class SysLogServiceImpl implements SysLogService {
	@Autowired
	SysLogRepository sysLogRepository;

	/**
	 * 保存SysLog实体类
	 * @param sysLog
	 * @return
	 */
	@Override
	public String savaLog(SysLog sysLog) {
		sysLogRepository.save(sysLog);
		return "success";
	}

	@Override
	public Page<SysLog> selectAllSysLog(int pageNum, int pageSize) {
		Sort sort = new Sort(Sort.Direction.ASC, "id");
		Pageable pageable = PageRequest.of(pageNum - 1, pageSize, sort);
		Page<SysLog> list = sysLogRepository.findAll(pageable);
		return list;
	}
}